//导航栏
var comUsername;
$(document).ready(function(){
	//------------退出-------------------
	$(".exit").click(function(){
		alert("退出登录！");
		window.localStorage.clear();
		window.sessionStorage.setItem("isLogin","false");
		window.location.href = "index.html";
	});
	$(".mydemand-head a").click(function () {
		window.location.href="index.html";
	})
	comUsername = window.localStorage.getItem("comUsername");
	$(".comUsername").html(comUsername);
	$.ajax({
		type:"POST",
		url:'http://59.110.114.107:8888/enterprise/InformationModification',
		data: {
			socialCode:comUsername
		},
		success: function (data) {
			$(".e_name").html(data.data.enterpriseName);
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
			alert("网络错误");
		}
	});
	//用作我的需求部分的html，不可删除
	var myDemandItem = $("#my-demand-item").html();
	var myRequestItem = $("#my-request-item").html();

	//发布需求部分加载
	$("#post-demand").click(function(){
		$(".post-demand").show();
		$(".my-demand").hide();
		$(".my-products").hide();
		$(".message").hide();
		$(".change-password").hide();
		//$(".product-details").hide();
		$(".business").hide();
		$(".my-request-product").hide();
		$("#post-demand").addClass("active");
		$("#my-demand,#products,#message,#change-password,#business,#my-request-product").removeClass("active");
	});

	//请求我的需求数据
	$("#my-demand").click(function(){
		debugger
		$(".my-demand").show();
		$(".post-demand").hide();
		$(".my-products").hide();
		//$(".product-details").hide();
		$(".business").hide();
		$(".my-request-product").hide();
		$(".message").hide();
		$(".change-password").hide();
		$("#my-demand").addClass("active");
		$("#post-demand,#products,#message,#change-password,#business,#my-request-product").removeClass("active");
		$.ajax({
			type:"POST",
			url:'http://59.110.114.107:8888/enterprise/checkdemand',
			data: {
				socialCode:comUsername
			},
			success: function (data) {
				$("#my-demand-tbody").html("<tr id=my-demand-item>"+myDemandItem+"</tr>");
				$.each(data.data,function(i,val){
					$("#my-demand-tbody").append("<tr id=my-demand-item"+i+">"+myDemandItem+"</tr>");
					$("#my-demand-item"+i).children().eq(0).text(val.enterpriseName);
					var loanLimit = val.loanLimit;
					if (loanLimit == "0") {loanLimit="100万及以下";}
					if (loanLimit == "1") {loanLimit="200万及以下";}
					if (loanLimit == "2") {loanLimit="300万及以下";}
					if (loanLimit == "3") {loanLimit="500万及以下";}
					if (loanLimit == "4") {loanLimit="1000万及以下";}
					if (loanLimit == "5") {loanLimit="1000万以上";}
					$("#my-demand-item"+i).children().eq(1).text(loanLimit);
					$("#my-demand-item"+i).children().eq(2).text(val.rateLowerLimit);
					$("#my-demand-item"+i).children().eq(3).text(val.rateUpperLimit);
					$("#my-demand-item"+i).children().eq(4).text(val.loanPeriod);
					var guaranteeMode = val.guaranteeMode;
					if (guaranteeMode == "0") { guaranteeMode = "抵押";}
					if (guaranteeMode == "1") { guaranteeMode = "信保基金";}
					if (guaranteeMode == "2") { guaranteeMode = "一般保证";}
					if (guaranteeMode == "3") { guaranteeMode = "信用";}
					if (guaranteeMode == "4") { guaranteeMode = "实际控制人夫妇提供个人连带担保";}
					$("#my-demand-item"+i).children().eq(5).text(guaranteeMode);
					$("#my-demand-item"+i).children().eq(6).text(val.financingPurposes);
					$("#my-demand-item"+i).children().eq(7).text(val.projectSituation);
					$("#my-demand-item"+i).children().eq(8).text(val.remark);
				});
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert(XMLHttpRequest.status);
				alert(XMLHttpRequest.readyState);
				alert(textStatus);
			}
		});
	});

	//请求我的申请数据
	$("#my-request-product").click(function(){
		$(".my-request-product").show();
		$(".post-demand").hide();
		$(".my-products").hide();
		//$(".product-details").hide();
		$(".business").hide();
		$(".my-demand").hide();
		$(".message").hide();
		$(".change-password").hide();
		$("#my-request-product").addClass("active");
		$("#post-demand,#products,#message,#change-password,#business,#my-demand").removeClass("active");

		$.ajax({
			type:"POST",
			url:'http://59.110.114.107:8888/enterprise/checkProductRequest',
			data: {
				socialCode:comUsername
			},
			success: function (data) {
				if(data.meta.success){
					$("#my-request-tbody").html("<tr id=my-demand-item>"+myRequestItem+"</tr>");
					//console.log(data.data.enterpriseProductRequestVOList);
					$.each(data.data.enterpriseProductRequestVOList,function(i,val){
						//console.log(val);
						$("#my-request-tbody").append("<tr id=my-request-item"+i+">"+myRequestItem+"</tr>");
						$("#my-request-item"+i).children().eq(0).text(val.fkProductName);
						$("#my-request-item"+i).children().eq(1).text(val.bankName);
						var loanLimit = val.loanLimit;
						if (loanLimit == "0") {loanLimit="100万及以下";}
						if (loanLimit == "1") {loanLimit="200万及以下";}
						if (loanLimit == "2") {loanLimit="300万及以下";}
						if (loanLimit == "3") {loanLimit="500万及以下";}
						if (loanLimit == "4") {loanLimit="1000万及以下";}
						if (loanLimit == "5") {loanLimit="1000万以上";}
						$("#my-request-item"+i).children().eq(2).text(loanLimit);
						$("#my-request-item"+i).children().eq(3).text(val.rateLowerLimit);
						$("#my-request-item"+i).children().eq(4).text(val.rateUpperLimit);
						$("#my-request-item"+i).children().eq(5).text(val.loanPeriod);
						$("#my-request-item"+i).children().eq(6).text(val.fundUsage);

						var time=val.requestTime.substr(0,16).replace('T'," ")
						$("#my-request-item"+i).children().eq(7).text(time);
						$("#my-request-item"+i).children().eq(8).text(val.status==0?"进行中":val.status==1?"已成功":"已拒绝");
					});
				}
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert(XMLHttpRequest.status);
				alert(XMLHttpRequest.readyState);
				alert(textStatus);
			}
		});
	});
	//金融产品请求数据
	$("#products").click(function(){
		$(".my-products").show();
		$(".post-demand").hide();
		$(".my-demand").hide();
		//$(".product-details").hide();
		$(".business").hide();
		$(".my-request-product").hide();
		$(".message").hide();
		$(".change-password").hide();
		$("#products").addClass("active");
		$("#post-demand,#my-demand,#message,#change-password,#business,#my-request-product").removeClass("active");

		var productsItem = $("#products-item").html();
		//待完成的查询功能，查询全部数据
		$.ajax({
			type:"POST",
			url:'http://59.110.114.107:8888/enterprise/productCheck/'+comUsername,
			data:{
				institutionType:"",
				loanLimit:"",
				loanPeriod:$("#products-loanPeriod").val(),
				guaranteeMode:"",
				internetLoanType:"",
				productProperties:""
			},
			success:function (data) {
				if (data.data == null) {
					console.log("无结果！");
					$(".products-list").html("<div class='products-item' id=products-item>"+productsItem+"</div>");
				}else{
					console.log("查询成功！");
					$(".products-list").html("<div class='products-item' id=products-item>"+productsItem+"</div>")
					$.each(data.data,function(i,val){
						$(".products-list").append("<div class='products-item' id=products-item"+i+">"+productsItem+"</div>");
						$("#products-item"+i+" a img").attr('src','images/'+val.bankName+'.png');
                        val.comUsername = comUsername;
                        var rowInfo = JSON.stringify(val);
                        $("#products-item"+i+" div.row-info").html("<input type='hidden'  value='"+rowInfo+"' />");
						$("#products-item"+i+" h4").html(val.bankName+"-<span>"+val.productName+"</span>");
						$("#products-item"+i+" em:eq(0)").html(val.rateLowerLimit+"%-"+val.rateUpperLimit+"%");
						var proloanLimit = val.loanLimit;
						if (proloanLimit == "0") {proloanLimit="100万及以下";}
						if (proloanLimit == "1") {proloanLimit="200万及以下";}
						if (proloanLimit == "2") {proloanLimit="300万及以下";}
						if (proloanLimit == "3") {proloanLimit="500万及以下";}
						if (proloanLimit == "4") {proloanLimit="1000万及以下";}
						if (proloanLimit == "5") {proloanLimit="1000万以上";}
						$("#products-item"+i+" em:eq(1)").html(proloanLimit);
						var proguaranteeMode = val.guaranteeMode;
						if (proguaranteeMode == "0") { proguaranteeMode = "抵押";}
						if (proguaranteeMode == "1") { proguaranteeMode = "信保基金";}
						if (proguaranteeMode == "2") { proguaranteeMode = "一般保证";}
						if (proguaranteeMode == "3") { proguaranteeMode = "信用";}
						if (proguaranteeMode == "4") { proguaranteeMode = "实际控制人夫妇提供个人连带担保";}
						$("#products-item"+i+" em:eq(2)").html(proguaranteeMode);
						var loanPeriod = val.loanPeriod;
						// if (loanPeriod >"0"&&loanPeriod <"3") { loanPeriod = "3个月及以下";}
						// if (loanPeriod >="3"&&loanPeriod <"6") { loanPeriod = "6个月及以下";}
						// if (loanPeriod >="6"&&loanPeriod <"12") { loanPeriod = "12个月及以下";}
						// if (loanPeriod >="12"&&loanPeriod <"36") { loanPeriod = "36个月及以下";}
						// if (loanPeriod >= "36") { loanPeriod = "36个月以上";}
						$("#products-item"+i+" em:eq(3)").html(loanPeriod+"月");

					});
					//};
				}
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert(XMLHttpRequest.status);
				alert(XMLHttpRequest.readyState);
				alert(textStatus);
			}
		});
	});

	//请求企业信息数据
	$("#message").click(function(){
		$(".message").show();
		$(".post-demand").hide();
		$(".my-demand").hide();
		//$(".product-details").hide();
		$(".business").hide();
		$(".my-request-product").hide();
		$(".my-products").hide();
		$(".change-password").hide();
		$("#message").addClass("active");
		$("#post-demand,#my-demand,#products,#change-password,#business,#my-request-product").removeClass("active");

		$.ajax({
			type:"POST",
			url:'http://59.110.114.107:8888/enterprise/InformationModification',
			data: {
				socialCode:comUsername
			},
			success: function (data) {
				//不可修改数据部分
				$(".enterpriseName").html(data.data.enterpriseName);
				$(".fundQuota").html(data.data.fundQuota);
				$(".available").html(data.data.available);
				$(".socialCode").html(data.data.socialCode);

				$("#registeredCaptial").val(data.data.registeredCaptial);
				$("#ownerName").val(data.data.ownerName);
				$("#street").val(data.data.street);
				$("#region").val(data.data.region);
				$("#establishTime").val(data.data.establishTime.substr(0, 10));
				$("#ownerPhone").val(data.data.ownerPhone);
				$("#contactName").val(data.data.contactName);
				$("#contactPhone").val(data.data.contactPhone);
				$("#establishAddress").val(data.data.establishAddress);
				$("#business_scop").val(data.data.businessScop);
				$("#longAndLat").val(data.data.longAndLat);
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert(XMLHttpRequest.status);
				alert(XMLHttpRequest.readyState);
				alert(textStatus);
			}
		});
	});

	//请求企业业务信息
	$("#business").click(function(){
			$(".business").show();
			$(".post-demand").hide();
			$(".my-demand").hide();
			//$(".product-details").hide();
			$(".message").hide();
			$(".my-request-product").hide();
			$(".my-products").hide();
			$(".change-password").hide();
			$("#business").addClass("active");
			$("#post-demand,#my-demand,#products,#change-password,#message,#my-request-product").removeClass("active");

            var itemList=$("#business_show span");

			$.ajax({
				type:"POST",
				url:'http://59.110.114.107:8888/enterprise/checkStatics',
				data: {
                    socialCode:comUsername
				},
				success: function (data) {
					if(data.meta.success){
					    var item =data.data;
					    //console.log(data.data);
                        itemList.eq(0).text(item.enterpriseReqCount);
                        itemList.eq(1).text(item.enterpriseReqAmountCount);
                        itemList.eq(2).text(item.productRequestCount);
                        itemList.eq(3).text(item.productRequestSuccessCount);
                        itemList.eq(4).text(item.productRequestSuccessAmountCount);
                        itemList.eq(5).text(item.productRequestApplyingCount);
                        itemList.eq(6).text(item.productRequestApplyingAmountCount);

                    }
				},
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					alert(XMLHttpRequest.status);
					alert(XMLHttpRequest.readyState);
					alert(textStatus);
				}
			});
		});

	//修改密码界面切换
	$("#change-password").click(function(){
		$(".change-password").show();
		$(".my-products").hide();
		$(".post-demand").hide();
		$(".business").hide();
		$(".my-request-product").hide();
		$(".my-demand").hide();
		$(".message").hide();
		$("#change-password").addClass("active");
		$("#post-demand,#my-demand,#message,#products,#business,#my-request-product").removeClass("active");
	});


	//发布需求功能
	$("#issue").click(function(){
		var loan_limit = $("#loan_limit").val().substr(0, 1);
		var guarantee_mode = $("#guarantee_mode").val().substr(0, 1);
		$.ajax({
			type:"POST",
			url:'http://59.110.114.107:8888/enterprise/requirementRelease',
			data: {
				enterpriseName:$("#e_name").text(),
				financingPurposes:$("#financing_purposes").val(),
				guaranteeMode:guarantee_mode,
				loanLimit:loan_limit,
				loanPeriod:$("#loan_period").val(),
				lowerLimmit:$("#rate_lower_limmit").val(),
				projrctSituation:$("#projrct_situation").val(),
				remark:$("#remark").val(),
				socialCode:comUsername,
				upperLimmit:$("#rate_upper_limmit").val()
			},
			success: function (data) {
				alert(data.meta.message);
				window.location.href = "company.html";
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert(XMLHttpRequest.status);
				alert(XMLHttpRequest.readyState);
				alert(textStatus);
			}
		});
	});

	//我的需求 查询功能
	$("#mydemand-btn").click(function(){
		//贷款额度
		var loanLimit = $(".loan_limit").val().substr(0, 1);
		//担保方式
		var guaranteeMode = $(".guarantee_mode").val().substr(0, 1);
		//利率下限
		var rateLowerLimit = $(".rate_lower_limmit").val();
		//利率上限
		var rateUpperLimit = $(".rate_upper_limmit").val();
		//融资期限
		var loanPeriod = $(".loan_period").val();
		$.ajax({
			type:"POST",
			url:'http://59.110.114.107:8888/enterprise/checkdemand',
			data: {
				socialCode:comUsername,
				loanLimit:loanLimit,
				rateLowerLimit:rateLowerLimit,
				rateUpperLimit:rateUpperLimit,
				loanPeriod:loanPeriod,
				guaranteeMode:guaranteeMode
			},
			success: function (data) {
				alert(data.meta.message);
				$("#my-demand-tbody").html("<tr id=my-demand-item>"+myDemandItem+"</tr>");
				$.each(data.data,function(i,val){
					$("#my-demand-tbody").append("<tr id=my-demand-item"+i+">"+myDemandItem+"</tr>");
                    var rowInfo = JSON.stringify(val);
                    $("#products-item"+i+" div.row-info").html("<input type='hidden' value='"+rowInfo+"'  >");
					$("#my-demand-item"+i).children().eq(0).text(val.enterpriseName);
					var loanLimit = val.loanLimit;
					if (loanLimit == "0") {loanLimit="100万及以下";}
					if (loanLimit == "1") {loanLimit="200万及以下";}
					if (loanLimit == "2") {loanLimit="300万及以下";}
					if (loanLimit == "3") {loanLimit="500万及以下";}
					if (loanLimit == "4") {loanLimit="1000万及以下";}
					if (loanLimit == "5") {loanLimit="1000万以上";}
					$("#my-demand-item"+i).children().eq(1).text(loanLimit);
					$("#my-demand-item"+i).children().eq(2).text(val.rateLowerLimit);
					$("#my-demand-item"+i).children().eq(3).text(val.rateUpperLimit);
					$("#my-demand-item"+i).children().eq(4).text(val.loanPeriod);
					var guaranteeMode = val.guaranteeMode;
					if (guaranteeMode == "0") { guaranteeMode = "抵押";}
					if (guaranteeMode == "1") { guaranteeMode = "信保基金";}
					if (guaranteeMode == "2") { guaranteeMode = "一般保证";}
					if (guaranteeMode == "3") { guaranteeMode = "信用";}
					if (guaranteeMode == "4") { guaranteeMode = "实际控制人夫妇提供个人连带担保";}
					$("#my-demand-item"+i).children().eq(5).text(guaranteeMode);
					$("#my-demand-item"+i).children().eq(6).text(val.financingPurposes);
					$("#my-demand-item"+i).children().eq(7).text(val.projectSituation);
					$("#my-demand-item"+i).children().eq(8).text(val.remark);
				});
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert(XMLHttpRequest.status);
				alert(XMLHttpRequest.readyState);
				alert(textStatus);
			}
		});

	});

	//企业信息修改功能
	$("#confirm").click(function(){
		var region = $("#region").val().substr(0, 1);
		$.ajax({
			type:"POST",
			url:'http://59.110.114.107:8888/enterprise/InformationModification/post',
			headers: {'Content-Type':'application/json'},
			data:  JSON.stringify({
				socialCode:$(".socialCode").text(),
				enterpriseName:$(".enterpriseName").text(),
				registeredCaptial:$("#registeredCaptial").val(),
				ownerName:$("#ownerName").val(),
				region:region,
				street:$("#street").val(),
				ownerPhone:$("#ownerPhone").val(),
				contactName:$("#contactName").val(),
				contactPhone:$("#contactPhone").val(),
				establishTime:$("#establishTime").val(),
				establishAddress:$("#establishAddress").val(),
				fundQuota:$(".fundQuota").text(),
				available:$(".available").text(),
				businessScop:$("#business_scop").val(),
				longAndLat:$("#longAndLat").val()
			}),
			success: function (data) {
				alert(data.meta.message);
				window.location.href = "company.html";
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert(XMLHttpRequest.status);
				alert(XMLHttpRequest.readyState);
				alert(textStatus);
			}
		});
	});

	//金融产品查询
	$("#products-search").click(function(){
		//担保方式
		var productsGuaranteeMode = $("#products-guaranteeMode").val().substr(0, 1);
		//机构类型
		var productsInstitutionType = $("#products-institutionType").val().substr(0, 1);
		//网贷直连
		var productsInternetLoanType = $("#products-internetLoanType").val().substr(0, 1);
		//贷款额度
		var productsLoanLimit = $("#products-loanLimit").val().substr(0, 1);
		//政策性产品
		var productProperties = $("#productProperties").val().substr(0, 1);

		if (productsGuaranteeMode == "不") {
			productsGuaranteeMode = "";
		}
		if (productsInstitutionType == "不") {
			productsInstitutionType = "";
		}
		if (productsInternetLoanType == "不") {
			productsInternetLoanType = "";
		}
		if (productsLoanLimit == "不") {
			productsLoanLimit = "";
		}
		if (productProperties == "不") {
			productProperties = "";
		}

		var productsItem = $("#products-item").html();
		$.ajax({
			type:"POST",
			url:'http://59.110.114.107:8888/enterprise/productCheck/'+comUsername,
			data:{
				institutionType:productsInstitutionType,
				loanLimit:productsLoanLimit,
				loanPeriod:$("#products-loanPeriod").val(),
				guaranteeMode:productsGuaranteeMode,
				internetLoanType:productsInternetLoanType,
				productProperties:productProperties
			},
			success: function (data) {
				if (data.data == null) {
					alert(data.meta.message);
					$(".products-list").html("<div class='products-item' id=products-item>"+productsItem+"</div>");
				}else{
					alert(data.meta.message);
					$(".products-list").html("<div class='products-item' id=products-item>"+productsItem+"</div>")
					$.each(data.data,function(i,val){
						$(".products-list").append("<div class='products-item' id=products-item"+i+">"+productsItem+"</div>");
                        val.comUsername=comUsername
						var rowInfo = JSON.stringify(val);
                        $("#products-item"+i+" div.row-info").html("<input type='hidden' value='"+rowInfo+"'  >");

						$("#products-item"+i+" h4").html(val.bankName+"-<span>"+val.productName+"</span>");
						$("#products-item"+i+" em:eq(0)").html(val.rateLowerLimit+"%-"+val.rateUpperLimit+"%");
						var proloanLimit = val.loanLimit;
						if (proloanLimit == "0") {proloanLimit="100万及以下";}
						if (proloanLimit == "1") {proloanLimit="200万及以下";}
						if (proloanLimit == "2") {proloanLimit="300万及以下";}
						if (proloanLimit == "3") {proloanLimit="500万及以下";}
						if (proloanLimit == "4") {proloanLimit="1000万及以下";}
						if (proloanLimit == "5") {proloanLimit="1000万以上";}
						$("#products-item"+i+" em:eq(1)").html(proloanLimit);
						var proguaranteeMode = val.guaranteeMode;
						if (proguaranteeMode == "0") { proguaranteeMode = "抵押";}
						if (proguaranteeMode == "1") { proguaranteeMode = "信保基金";}
						if (proguaranteeMode == "2") { proguaranteeMode = "一般保证";}
						if (proguaranteeMode == "3") { proguaranteeMode = "信用";}
						if (proguaranteeMode == "4") { proguaranteeMode = "实际控制人夫妇提供个人连带担保";}
						$("#products-item"+i+" em:eq(2)").html(proguaranteeMode);
						var loanPeriod = val.loanPeriod;
						if (loanPeriod == "0") { loanPeriod = "3个月及以下";}
						if (loanPeriod == "1") { loanPeriod = "6个月及以下";}
						if (loanPeriod == "2") { loanPeriod = "12个月及以下";}
						if (loanPeriod == "3") { loanPeriod = "36个月及以下";}
						if (loanPeriod == "4") { loanPeriod = "36个月以上";}
						$("#products-item"+i+" em:eq(3)").html(loanPeriod);
					});
					//};
				}
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert(XMLHttpRequest.status);
				alert(XMLHttpRequest.readyState);
				alert(textStatus);
			}
		});
	});

	//修改企业密码
	$("#changeSure").click(function(){
		$.ajax({
			type:"POST",
			url:'http://59.110.114.107:8888/enterprise/changepassword',
			data:{
				newPassword:$("#newPassword").val(),
				password:$("#password").val(),
				username:comUsername
			},
			success: function (data) {
				alert(data.meta.message);
				window.location.href = "company.html";
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert(XMLHttpRequest.status);
				alert(XMLHttpRequest.readyState);
				alert(textStatus);
			}
		});

	});


	//金融产品详情立即申请
	// $("#apply-immediately").click(function(){
	// 	var productName=$("#prodetails-productName").text();
	// 	$.ajax({
	// 		type:"POST",
	// 		url:'http://59.110.114.107:8888/enterprise/productRequest/'+productName,
	// 		data: {
	// 			socialCode:comUsername,
	// 			productName:productName,
	// 			fundUsage:$("#fundUsage").val()
	// 		},
	// 		success: function (data) {
	// 			alert(data.meta.message);
	// 			window.location.href="company.html";
	// 		},
	// 		error: function(XMLHttpRequest, textStatus, errorThrown) {
	// 			alert(XMLHttpRequest.status);
	// 			alert(XMLHttpRequest.readyState);
	// 			alert(textStatus);
	// 		}
	// 	});
	// });

	//金融产品详情返回
	// $("#return").click(function(){
	// 	$(".my-products").show();
	// 	$(".product-details").hide();
	// });

	$("#toBDMap").click(function(){
		console.log("toBDMap")
		window.open("http://api.map.baidu.com/lbsapi/getpoint/","_blank");
	})

});

//金融产品申请
function apply(which){
	var productName=$(which).parent().prev().children("h4").children().html();
	var productList = $(which).parent().parent();
	var fundUsage=$(which).parent().prev().children("span").eq(4).children("input").val();
	//console.log(fundUsage);
	$.ajax({
		type:"POST",
		url:'http://59.110.114.107:8888/enterprise/productRequest/'+productName,
		data: {
			socialCode:comUsername,
			productName:productName,
			fundUsage:fundUsage
		},
		success: function (data) {
			alert(data.meta.message);
			productList.remove();
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
			alert(XMLHttpRequest.status);
			alert(XMLHttpRequest.readyState);
			alert(textStatus);
		}
	});
};

//金融产品详情查看
function proDetail(which){
	//var productName=$(which).parent().prev().children("h4").children().html();
	var arr=$(which).parent().prev().children("h4").text().split("-");

	sessionStorage.setItem("detailBankName",arr[0]);
	sessionStorage.setItem("detailProductName",arr[1]);
	//当前版本没有这里没有分页，默认是第一页
	sessionStorage.setItem("pageNum","1");
	window.location.href="productsDetail_1.html";

};

//短信发送
function msgSend(which){

    var rowInfo=$(which).parent().prev().children(".row-info").children("input").val();
    rowInfo = JSON.parse(rowInfo);
    var fkBankId = rowInfo.fkBankId;
    var comUsername = window.localStorage.getItem("comUsername");
    if(null == comUsername || '' == comUsername || undefined == comUsername){
        alert("请先登录")
	}else{
        $.ajax({
            type:"POST",
            url:'http://59.110.114.107:8888/enterprise/sendMsg',
            data: {
                socialCode:comUsername,
                fkBankId:fkBankId
            },
            success: function (data) {
                debugger
                alert(data.meta.message);
            }
        });

    }


};
